package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HousingOrder;
import com.ruoyi.system.service.IHousingOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 交易管理Controller
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@RestController
@RequestMapping("/system/housing/order")
public class HousingOrderController extends BaseController
{
    @Autowired
    private IHousingOrderService housingOrderService;

    /**
     * 查询交易管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(HousingOrder housingOrder)
    {
        startPage();
        List<HousingOrder> list = housingOrderService.selectHousingOrderList(housingOrder);
        return getDataTable(list);
    }

    /**
     * 导出交易管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:order:export')")
    @Log(title = "交易管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HousingOrder housingOrder)
    {
        List<HousingOrder> list = housingOrderService.selectHousingOrderList(housingOrder);
        ExcelUtil<HousingOrder> util = new ExcelUtil<HousingOrder>(HousingOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取交易管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:order:query')")
    @GetMapping(value = "/{hoId}")
    public AjaxResult getInfo(@PathVariable("hoId") Long hoId)
    {
        return AjaxResult.success(housingOrderService.selectHousingOrderById(hoId));
    }

    /**
     * 新增交易管理
     */
//    @PreAuthorize("@ss.hasPermi('system:order:add')")
    @Log(title = "交易管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HousingOrder housingOrder)
    {
        return toAjax(housingOrderService.insertHousingOrder(housingOrder));
    }

    /**
     * 修改交易管理
     */
//    @PreAuthorize("@ss.hasPermi('system:order:edit')")
    @Log(title = "交易管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HousingOrder housingOrder)
    {
        return toAjax(housingOrderService.updateHousingOrder(housingOrder));
    }

    /**
     * 删除交易管理
     */
//    @PreAuthorize("@ss.hasPermi('system:order:remove')")
    @Log(title = "交易管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hoIds}")
    public AjaxResult remove(@PathVariable Long[] hoIds)
    {
        return toAjax(housingOrderService.deleteHousingOrderByIds(hoIds));
    }
}
